package cn.cas.mango.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class EsTypeTransUtil {
  public static List<String> keyword2List(Object o){
    List<Map> searchingKeywords = new ArrayList<>();
    if (o instanceof String) {
      searchingKeywords.add((Map) o);
    } else if (o instanceof List) {
      searchingKeywords.addAll((List<Map>) o);
    }
    return searchingKeywords.stream().map(x->((String)x.get("name"))).collect(Collectors.toList());
  }
  public static List<String> entity2List(Object o){
    List<String> searchingKeywords = new ArrayList<>();
    if (o instanceof String) {
      searchingKeywords.add((String) o);
    } else if (o instanceof List) {
      searchingKeywords.addAll((List<String>) o);
    }
    return searchingKeywords;
  }
}
